package cn.itsource.system.listener;

import cn.itsource.system.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

@WebListener
public class PermissionScanInitListener implements ServletContextListener {

    @Autowired
    private IPermissionService permissionService;

    //上下文对象一创建，自动调用该方法
    @Override
    public void contextInitialized(ServletContextEvent servletContextEvent) {
        System.out.println("开始扫描");
        //扫描注解加权限
        permissionService.scanPermission();
        System.out.println("结束扫描");
    }
    //上下文对象一销毁，自动调用该方法
    @Override
    public void contextDestroyed(ServletContextEvent servletContextEvent) {
    }
}
